Codeforces Round 984 Problem E. Reverse The Rivers Full Solution In C++